﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace EFCore一对多关系配置
{
  public class ArticleConfig : IEntityTypeConfiguration<Article>
  {
    public void Configure(EntityTypeBuilder<Article> builder)
    {
      builder.ToTable("T_Acticle");
      builder.Property(a=>a.Title).HasMaxLength(100).IsUnicode().IsRequired();
      builder.Property(a=>a.Message).IsUnicode().IsRequired();

      builder.HasQueryFilter(a => a.Id > 1);//全局查询过滤筛选器 应用场景：软删除、多租户
    }
  }
}
